#include<bits/stdc++.h>
#define gc getchar
#define pc putchar
using namespace std;
int read(){
    int x=0,f=1;
    char ch=gc();
    while(!isdigit(ch) && ch!='-')ch=gc();
    if(ch=='-'){
        f=-1;
        ch=gc();
    }
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+(ch^48);
        ch=gc();
    }
    return x*f;
}
void print(int x){
    if(x<0){
        pc('-');
        x=-x;
    }
    if(x<10){
        pc(x^48);
        return;
    }
    print(x/10);
    pc((x%10)^48);
}
struct cars{
    int a,d,v;
    double d2;
}A[100100];
int b[100100];
bool subA=true,subB=true;
int n,m,l,v;
double nowv(int id,int mid){
    double d=A[id].v*A[id].v+2.0*A[id].a*(b[mid]-A[id].d);
    if(d<0)return -0.1;
    return sqrt(d);
}
int BSa(int id){
    int l=1,r=m;
    int ans=-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(b[mid]>=A[id].d && A[id].v>v){
            ans=mid;
            r=mid-1;
        }else l=mid+1;
    }
    return ans;
}
int BSb(int id){
    int l=1,r=m;
    int ans=-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(nowv(id,mid)>v && b[mid]>=A[id].d){
            ans=mid;
            r=mid-1;
        }else l=mid+1;
    }
    return ans;
}
int BSc(int id){
    int l=1,r=m;
    int ans=-1;
    while(l<=r){
        int mid=(l+r)>>1;
      //  cout<<l<<' '<<r<<' '<<mid<<' '<<nowv(id,mid)<<endl;
        if(nowv(id,mid)<=v){
            ans=mid;
            r=mid-1;
        }else l=mid+1;
    }
    return ans;
}
vector<int> CS[50];
bool choose[50];
int fg[50];
int ans=114514;
void dfs(int now,int dep){
    if(now>=ans)return;
    if(dep>m){
        for(int i=1;i<=n;i++){
           // print(fg[i]),pc(' ');
            if(!fg[i]){return;}
        }

        ans=min(ans,now);
        return;
    }
    for(int i=0;i<=1;i++){
        if(CS[i].size()==0 && i==1)continue;
        choose[dep]=i;
        if(i==1)for(int j=0;j<CS[dep].size();j++)fg[CS[dep][j]]++;
        dfs(now+i,dep+1);
        if(i==1)for(int j=0;j<CS[dep].size();j++)fg[CS[dep][j]]--;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T=read();
    while(T--){
        n=read(),m=read(),l=read(),v=read();
        for(int i=1;i<=n;i++){
            A[i].d=read(),A[i].v=read(),A[i].a=read();
            if(A[i].a<0)subA=subB=false,A[i].d2=(double)A[i].d+(double)A[i].a*A[i].a*A[i].a/2.0/A[i].v/A[i].v-A[i].a;
            if(A[i].a>0)subA=false;
            if(A[i].a==0)subB=false;
        }
        for(int i=1;i<=m;i++)b[i]=read();
        if(subA){
            int cnt1=0;
            for(int i=1;i<=n;i++){
                if(A[i].d<=b[m] && A[i].v>v)cnt1++;
            }
            print(cnt1),pc(' '),print(m-(cnt1!=0)),pc('\n');
            continue;
        }
        if(subB){
            int cnt1=0;
            for(int i=1;i<=n;i++){
                if(A[i].d<=b[m] && nowv(i,m)>v)cnt1++;
            }
            print(cnt1),pc(' '),print(m-(cnt1!=0)),pc('\n');
            continue;
        }
        if(n<=20 && m<=20){
            ans=114514;
            memset(fg,0,sizeof(fg));
            memset(CS,0,sizeof(CS));
            int cnt1=n,cnt2=0;
            for(int i=1;i<=n;i++){
                if(A[i].a==0){
                    int bg=BSa(i);
                    //cout<<"bg:"<<bg<<endl;
                    if(bg!=-1)for(int j=bg;j<=m;j++)CS[j].push_back(i);
                    else fg[i]=114514,cnt1--;
                }else if(A[i].a>0){
                    int bg=BSb(i);
                    //cout<<"bg:"<<bg<<endl;
                    if(bg!=-1)for(int j=bg;j<=m;j++)CS[j].push_back(i);
                    else fg[i]=114514,cnt1--;
                }else{
                    if(A[i].v>v){
                        int bg1=BSa(i);
                        int bg2=BSc(i);
                       // cout<<"bg:"<<bg1<<' '<<bg2<<endl;
                        if(bg2==-1)bg2=m+1;
                        if(bg1<bg2 && bg1!=-1)for(int j=bg1;j<bg2;j++)CS[j].push_back(i);
                        else fg[i]=114514,cnt1--;
                    }else cnt1--,fg[i]=114514;
                }
                //print(cnt1),pc(' ');
            }
            //pc('\n');
/*
            for(int i=1;i<=m;i++){
                for(int j=0;j<CS[i].size();j++)cout<<CS[i][j]<<' ';
                cout<<endl;
            }*/
            dfs(0,1);
            if(ans==114514)ans=0;
            print(cnt1),pc(' '),print(m-ans),pc('\n');
        }
    }

}
/*
STO TheSky233 Orz
STO LXGOD Orz
STO rym Orz
STO czx Orz
rp+=inf;
luogu_uid=1038710
STO give me 1= please Orz
*/
